<?php

namespace app\admin\controller;

use \think\Request;

class Base extends \think\Controller
{
    public function _initialize()
    {
        //判断是否有登录
        $admin_id = session("admin_id");
        if (empty($admin_id)) {
            session(null);
            //跳转到登录页
            $this->error('你还未登录', 'admin/login/login');
        } else {
            //记录当前页面，以便加激活类
            define('MODULE_NAME', strtolower(Request::instance()->module()));
            define('CONTROLLER_NAME', strtolower(Request::instance()->controller()));
            define('ACTION_NAME', strtolower(Request::instance()->action()));
            $this->assign([
                "MODULE_NAME" => MODULE_NAME
                , "CONTROLLER_NAME" => CONTROLLER_NAME
                , "ACTION_NAME" => ACTION_NAME
            ]);
        }
    }
}